using Microsoft.Xna.Framework;

namespace WPCoco.Tasks
{
    public class SkewBy : TargetedTask<IAffine>
    {
        public SkewBy(Vector2 skew, float duration)
            : base(duration)
        {
            this.skew = skew;
        }

        Vector2 skew;
        Vector2 delta;
        Vector2 start;

        public override void InitializeWithTarget(IAffine target)
        {
            start = target.Skew;
            delta = skew / Duration;
        }

        public override void UpdateWithTarget(IAffine target, float time)
        {
            target.Skew = start + delta * time;
        }

        public override Task Clone()
        {
            return new SkewBy(skew, Duration);
        }

        public override Task Reverse()
        {
            return new SkewBy(-skew, Duration);
        }
    }
}
